package top.iridescent.kafka;


import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class KafkaConsumer {
    // 消费监听
    @KafkaListener(topics = {"test2"},groupId = "g1")
    public void onMessage1(ConsumerRecord<?, ?> record){
        // 消费的哪个topic、partition的消息,打印出消息内容
        System.out.println("消费者1-1简单消费:  topic："+record.topic()+"-partition: "+record.partition()+"- value: "+record.value());
    }

    // 消费监听
    @KafkaListener(topics = {"test2"},groupId = "g1")
    public void onMessage2(ConsumerRecord<?, ?> record){
        // 消费的哪个topic、partition的消息,打印出消息内容
        System.out.println("消费者1-2简单消费：topic："+record.topic()+"-partition: "+record.partition()+"- value: "+record.value());
    }
}
